#![no_std]
#![no_main]

// pick a panicking behavior
use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch panics
// use panic_abort as _; // requires nightly
// use panic_itm as _; // logs messages over ITM; requires ITM support
// use panic_semihosting as _; // logs messages to the host stderr; requires a debugger

use cortex_m::asm;
use cortex_m_rt::entry;

use stm32f1xx_hal::flash::FlashExt;
use stm32f1xx_hal::pac::Peripherals;

use stm32f1xx_hal::prelude::{
    _stm32_hal_gpio_GpioExt,
    _stm32_hal_rcc_RccExt,
    // _fugit_ExtU32,
    _fugit_RateExtU32,
};

use fire_rs::board::Board;

#[entry]
fn main() -> ! {
    asm::nop(); // To not have main optimize to abort in release mode, remove when you add code

    let dp = Peripherals::take().unwrap();

    let rcc = dp.RCC.constrain();
    let mut flash = dp.FLASH.constrain();

    rcc.cfgr.use_hse(8.MHz()).sysclk(72.MHz()).freeze(&mut flash.acr);

    let mut gpiob = dp.GPIOB.split();
    let pb0 = gpiob.pb0.into_push_pull_output(&mut gpiob.crl);
    let pb1 = gpiob.pb1.into_push_pull_output(&mut gpiob.crl);
    let pb5 = gpiob.pb5.into_push_pull_output(&mut gpiob.crl);

    let mut led = Board::take_led(pb5, pb0, pb1);

    // led.turn_off();
    led.turn_off()
        .turn_on_blue()
        .turn_on_green()
        .turn_off_red();
        

    loop {
        // your code goes here
    }
}
